package com.tucy.logistics.modules.organization.controller;

import com.tucy.logistics.common.entity.organization.OrganizationPosition;
import com.tucy.logistics.common.result.Result;
import com.tucy.logistics.modules.organization.service.OrganizationPositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/9/15
 * description: 地理位置
 */
@Api(tags = "地理位置")
@RestController
@RequestMapping("/position")
public class OrganizationPositionController {

    @Autowired
    OrganizationPositionService positionService;

    @ApiOperation(value = "更新地理位置")
    @GetMapping("/restock")
    public Result<Boolean> restock() {
        return Result.success(positionService.restock());
    }

    @ApiOperation(value = "查询省级单位")
    @GetMapping("/queryProvincePosition")
    public Result<List<OrganizationPosition>> queryProvincePosition() {
        return Result.success(positionService.queryProvincePosition());
    }

    @ApiOperation(value = "查询省市县")
    @GetMapping("/queryThreePosition/{provinceId}")
    public Result<List<OrganizationPosition>> queryThreePosition(@PathVariable("provinceId") Long provinceId) {
        return Result.success(positionService.queryThreePosition(provinceId));
    }

    @ApiOperation(value = "查询地理详情")
    @GetMapping("/queryPositionDetails/{id}")
    public Result<OrganizationPosition> queryPositionDetails(@PathVariable("id") Long id) {
        return Result.success(positionService.getBaseMapper().selectById(id));
    }

}
